#include "game.h"
//输赢判定函数
int selectwin(int a[16][16],int i, int j){
    //12点钟方向开始，顺时针判断
    //横向
    for(int i=1; i<16; i++){
        for( int j=1; j<16; j++){
            if(a[i][j]==a[i][j+1] && a[i][j+1]==a[i][j+2] && a[i][j+2]==a[i][j+3] && a[i][j+3]==a[i][j+4] && a[i][j]!=43){
                return a[i][j];
            }
        }
    }
    //纵向
    for(int i=1; i<16; i++){
        for( int j=1; j<16; j++){
            if(a[i][j]==a[i+1][j] && a[i+1][j]==a[i+2][j] && a[i+2][j]==a[i+3][j] && a[i+3][j]==a[i+4][j] && a[i][j]!=43){
                return a[i][j];
            }
        }
    }
    //主对角线
    for(int i=1; i<16; i++){
        for(int j=1; j<16; j++){
            if(a[i][j]==a[i+1][j+1] && a[i+1][j+1]==a[i+2][j+2] && a[i+2][j+2]==a[i+3][j+3] && a[i+3][j+3]==a[i+4][j+4] && a[i][j]!=43){
                return a[i][j];        
            }
        }
    }
    //副对角线
    for(int i=1; i<16; i++){
        for(int j=1; j<16; j++){
            if(a[i][j]==a[i-1][j+1] && a[i-1][j+1]==a[i-2][j+2] && a[i-2][j+2]==a[i-3][j+3] && a[i-3][j+3]==a[i-4][j+4] && a[i][j]!=43){
                return a[i][j];        
            }
        } 
    }
    return 0;
}  